cmake_minimum_required(VERSION 3.5)

project(Chicken)

set(SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/Chicken.cpp)

# 设置 rpath 参数
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")

if(APPLE)
    set(CMAKE_INSTALL_RPATH "@executable_path/../lib")
elseif(UNIX)
    set(CMAKE_INSTALL_RPATH "$ORIGIN/../lib")
endif()

add_library(Chicken_lib SHARED ${CMAKE_CURRENT_SOURCE_DIR}/Chicken.cpp)

include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)
link_directories(${CMAKE_CURRENT_SOURCE_DIR}/lib)

add_executable(Chicken ${SOURCES})
target_link_directories(Chicken PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/lib)
target_link_libraries(Chicken Chicken_lib)


add_custom_target(docs
    COMMAND ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile
    WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
    COMMENT "Generating documentation with Doxygen"
)

install(TARGETS Chicken DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)
install(TARGETS Chicken_lib DESTINATION ${CMAKE_INSTALL_PREFIX}/lib)
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/ DESTINATION
  ${CMAKE_INSTALL_PREFIX}/include)



